package acmCoder;

import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by shuowu on 2017/10/27.
 */
public class MaxValue {
    private static final int MAX = 100000;
    private int[] array = new int[MAX];

    public static void main(String[] args){
        MaxValue object = new MaxValue();
        object.getRes();
    }

    public void getRes(){
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        while(scanner.hasNext()){
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                array[i] = scanner.nextInt();
            }
            Arrays.sort(array, 0, n);
            long res = 0;
            long cur = array[n - 1] + array[n - 2];
            for(int i = n - 1; i > 0; i--){
                res += cur * i;
                if(i != 1){
                    cur = array[i - 2];
                }
            }
            System.out.println(res);
        }
        scanner.close();
    }
}
